﻿using Domain.Entity.Config;
using Domain.Repository.IConfig;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EFCore.Repository.Config
{
    public class Config_major_kindRepository : IConfig_major_kindRepository
    {
        private readonly MyDbContext myDbContext;

        public Config_major_kindRepository(MyDbContext myDbContext)
        {
            this.myDbContext = myDbContext;
        }

        //添加
        public async Task<int> AddEIAsync(Config_major_kind config_Major)
        {
            myDbContext.config_Major_Kinds.Add(config_Major);
            return await myDbContext.SaveChangesAsync();
        }
        //删除
        public async Task<int> DeleteEIAsync(int Id)
        {
            Config_major_kind cmk = new Config_major_kind()
            {
                Mfk_id = Id
            };
            myDbContext.config_Major_Kinds.Remove(cmk);
            return await myDbContext.SaveChangesAsync();
        }

        //查询
        public async Task<List<Config_major_kind>> SelectCMKAsync()
        {
            return await myDbContext.config_Major_Kinds.ToListAsync();
        }

        public List<Config_major_kind> WenId(int Id)
        {
            return myDbContext.config_Major_Kinds.Where(e => e.Mfk_id == Id).ToList();    
        }
    }
}
